<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="/js/axios.min.js"></script>
    <script src="/js/util.js"></script>
    <script>
        window.onload = function () {
            findByItem(1);
        }

        function findByItem(pageNO) {

            axios.get("/user/findByItem", {
                params: {
                    pageNO: pageNO,
                    movieName: $("movieName").value,
                    cinema: $("cinema").value,
                    seriesName: $("seriesNum").value,
                    row: $("row").value
                }
            }).then(resp => {
                var info = resp.data;
                var dataStr = "";
                info.records.forEach(n => {
                    dataStr += `<tr>
                <td>${n.ticketId}</td>
                <td>${n.movieName}</td>
                <td>${n.seriesNum}</td>
                <td>${n.cinema}</td>
                <td>${n.row}</td>
                <td>${n.seat}</td>
                <td>${n.status}</td>
                <td><a href="javascript:order('${n.movieName}','${n.seriesNum}','${n.cinema}','${n.row}','${n.seat}')">下单</a></td>`;
                });
                $("data").innerHTML = dataStr;
                var cutDivStr = "";
                for (var i = 1; i <= info.pages; i++) {//分页页码
                    cutDivStr += `<a href="javascript:findByItem(${i})">${i}</a>`;
                }
                $("cutDiv").innerHTML = cutDivStr;
            })
        }

        function order(movieName, seriesNum, cinema, row, seat) {
            axios.get("/user/addOrder", {
                params: {
                    movieName: movieName,
                    seriesNum: seriesNum,
                    cinema: cinema,
                    row: row,
                    seat: seat
                }
            }).then(resp=>{
                if (resp.data=="ok"){
                    alert("添加成功")
                }
            })

        }
        function myOrder(){
            location.href="/orderInfo.html"
        }
    </script>
</head>
<body>
<table border="1" cellspacing="0" width="80%">
    <thead>
    <tr>
        <th>编号</th>
        <th>电影名称</th>
        <th>场次</th>
        <th>影院</th>
        <th>排号</th>
        <th>座号</th>
        <th>状态</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody id="data"></tbody>
</table>
<div id="cutDiv"></div>
电影名称：<input type="text" id="movieName"><br>
电影院名称：<input type="text" id="cinema"><br>
场次：<input type="text" id="seriesNum"><br>
排号：<input type="text" id="row"><br>
<input type="button" value="查询" onclick="findByItem(1)">
<input type="button" value="查看我的订单" onclick="myOrder()">

</body>
</html>